package com.project.sumup;

import java.util.ArrayList;
import java.util.Random;

public class RandomGenerator {

	public static ArrayList<Integer> RandomIntegers(int count, int aStart,
			int aEnd) {
		ArrayList<Integer> randoms = new ArrayList<Integer>();
		Random aRandom = new Random();
		for (int i = 0; i < count; ++i) {
			randoms.add(RandomInteger(aStart, aEnd, aRandom));

		}

		return randoms;
	}

	public static int RandomInteger(int aStart, int aEnd, Random aRandom) {
		if (aStart > aEnd) {
			throw new IllegalArgumentException("Start cannot exceed End.");
		}
		// get the range, casting to long to avoid overflow problems
		long range = (long) aEnd - (long) aStart + 1;
		// compute a fraction of the range, 0 <= frac < range

		long fraction = (long) (range * aRandom.nextDouble());
		int randomNumber = (int) (fraction + aStart);
		return randomNumber;
	}
}
